<template>
	<BaseContainer>
		<aplid-base-crud ref="crud" class="w-100" v-bind="{ ...baseConfig, ...$attrs }" :operateFormate="onOperateFormate"> </aplid-base-crud>
	</BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig, api } from './config'
import { ElMessage, ElMessageBox } from 'element-plus'
import apiMod from '@/apiMod/index'

const crud = ref(null)
//  处理刷新
const handleRefresh = (query?: any) => {
	nextTick(() => {
		crud.value.refreshChange(query)
	})
}

const onOperateFormate = (data, type) => {
	return new Promise((resolve, reject) => {
		if (type == 'revoke') {
			ElMessageBox.confirm(`请确认是否要撤回本次申请离院?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning',
			})
				.then(() => {
					apiMod[api.revoke]({ id: data.id }).then(() => {
						ElMessage({
							type: 'success',
							message: '撤销成功',
						})
						handleRefresh({})
					})
				})
				.catch(() => {})
		} else {
			resolve(data)
		}
	})
}


</script>

<style lang="scss" scoped></style>
